#ifndef _SCRIPTENGINE_
#define _SCRIPTENGINE_

#include "lua.hpp"
#include "lualib.h"
#include "Scriptable.hpp"
#include <string>
#include <iostream>

/** 
* Engine used to manage lua scripting.
*/
class ScriptEngine{
private:
    
protected:
    /** 
    * The lua state of this engine.
    */
    lua_State* luaState;
    
public:

    ScriptEngine();

    void loadScript(const char* name);

    void pushScriptable(Scriptable* scriptable);
    void pushString(const char* name);

    bool getBool();

    void loadFunction(const char* name);
    bool loadAndRun(const char* name);
    bool run(int nargs, int nret);

    void registerClass(Scriptable* scriptable);
    void registerFunction(const char* name, lua_CFunction function);


    ~ScriptEngine();
};
#endif